package com.test.videoplayer.activity.play;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import com.test.videoplayer.helper.IntentKeys;
import com.test.videoplayer.R;


public class DKActivity extends AppCompatActivity implements View.OnClickListener {
    private static final String VOD_URL = "http://vfx.mtime.cn/Video/2019/03/12/mp4/190312143927981075.mp4";
    //private static final String LIVE_URL = "rtmp://58.200.131.2:1935/livetv/hunantv";
    //private static final String LIVE_URL = "http://ivi.bupt.edu.cn/hls/cctv6.m3u8";
    //private static final String LIVE_URL = "http://192.168.0.141:2019/live?app=live&stream=012345678912.1";
   private String LIVE_URL = "rtmp://202.69.69.180:443/webcast/bshdlive-pc";
    //private static final String LIVE_URL = "rtmp://202.69.69.180:443/webcast/bshdlive-pc";
    //private static final String LIVE_URL = "rtsp://ajj:12345678@218.21.217.122:65523/h264/ch40/sub/av_stream";
    Button btnDPlayer,btnZPlayer,btnMOreZPlayer,btnMOreZPlayerTest;
    EditText etInput;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_dk);
        init();
    }
    private void init() {
        btnDPlayer = findViewById(R.id.btnDPlayer);
        btnZPlayer = findViewById(R.id.btnZPlayer);
        btnMOreZPlayer = findViewById(R.id.btnMOreZPlayer);
        btnMOreZPlayerTest = findViewById(R.id.btnMOreZPlayerTest);
        etInput = findViewById(R.id.etInput);
        btnDPlayer.setOnClickListener(this);
        btnZPlayer.setOnClickListener(this);
        btnMOreZPlayer.setOnClickListener(this);
        btnMOreZPlayerTest.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        int id = view.getId();
        switch (id) {
            case R.id.btnDPlayer: {
                Intent intent = new Intent(this, PlayerActivity.class);
                intent.putExtra(IntentKeys.URL, VOD_URL);
                intent.putExtra(IntentKeys.IS_LIVE, false);
                intent.putExtra(IntentKeys.TITLE, "点播");
                startActivity(intent);
                break;
            }
            case R.id.btnZPlayer: {
                String etInputName = etInput.getText().toString();
                if(TextUtils.isEmpty(etInputName)){
                    this.LIVE_URL = LIVE_URL;
                }else{
                    LIVE_URL = etInputName;
                }
                Intent intent = new Intent(this, PlayerActivity.class);
                intent.putExtra(IntentKeys.URL, LIVE_URL);
                intent.putExtra(IntentKeys.IS_LIVE, true);
                intent.putExtra(IntentKeys.TITLE, "直播");
                startActivity(intent);
                break;
            }
            case R.id.btnMOreZPlayer: {
                startActivity(new Intent(this, ParallelPlayActivity.class));
                break;
            }
            case R.id.btnMOreZPlayerTest: {
                startActivity(new Intent(this, ParallelPlayTestActivity.class));
                break;
            }
            default:
                break;
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
       // Log.d("Tag","11111111111111");
    }
}
